import {createHashRouter, RouteObject} from 'react-router-dom';
import Layout from '@/pages/layout';
import Home from '@/pages/home';
import Datasource from "@/pages/datasource";
import React from "react";
import Dashboard from "@/pages/dashboard";
import {
    IconBox,
    IconHistogram,
    IconHome, IconSetting,
} from "@douyinfe/semi-icons";
import Setting from "@/pages/setting";
import Ai from "@/pages/setting/ai";

// 定义包含自定义属性的路由接口
export interface AppRouteObject extends Omit<RouteObject, 'children'> {
    show?: boolean;
    icon?: React.ReactNode; // 或者更具体的类型，比如 React.ReactNode
    title?: string;
    children?: AppRouteObject[]; // 子路由也使用这个新接口
}


// 使用新的接口类型来定义 routes
export const routes: AppRouteObject[] = [
    {
        path: '/',
        element: <Layout/>,
        children: [
            {
                path: '/',
                element: <Home/>,
                show: true,
                icon: <IconHome/>, // 示例 Icon 名称
                title: '首页'
            },
            {
                path: '/datasource',
                element: <Datasource/>,
                show: true,
                icon: <IconBox/>, // 示例 Icon 名称
                title: '数据源'
            },
            {
                path: '/dashboard',
                element: <Dashboard/>,
                show: true,
                icon: <IconHistogram/>, // 示例 Icon 名称
                title: '数据看板'
            },
            {
                path: '/setting',
                element: <Setting/>,
                show: true,
                icon: <IconSetting/>,
                title: "设置",
                children: [
                    {
                        path: "ai",
                        element: <Ai/>,
                    }
                ]
            }
            // 你可以在这里添加更多子路由，它们也需要符合 AppRouteObject 接口
        ]
    }
    // 你可以在这里添加更多顶级路由
];

// createHashRouter 仍然可以接受 AppRouteObject[]
// 因为 AppRouteObject 扩展自 RouteObject，类型是兼容的
const router = createHashRouter(routes as RouteObject[]); // 可以选择性地断言回 RouteObject[]，虽然通常不需要

export default router;